<style lang="less">
	page{
		background: #f6f6f6;
	}
	// 头部
	.top-main{
		margin: 20upx 0 0;
		.main-top{
			// padding: 20upx 30upx;
			background: #FFFFFF;
			.main-top-top{
				padding: 20upx 30upx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				border-bottom: 1upx solid #EDEDED;
				.main-top-top-fl{
					font-size:30upx;
					font-weight:bold;
					color:rgba(51,51,51,1);
					padding-right: 38upx;
					background: url('https://static.xpandago.net/wechat/images/tc_tipicon%402x.png') no-repeat right center;
					background-size: 26upx;
				}
			}
			.main-top-fl{
				padding: 20upx 30upx;
				display: flex;
				align-items:center;
				.touxiang{
					width: 70upx;
					height: 70upx;
					overflow: hidden;
					border-radius: 50%;
				}
				.name-info{
					margin-left: 10upx;
					overflow: hidden;
					width: calc(100% - 90upx);
					.name{
						font-size: 24upx;
						font-weight: bold;
						color: #333333;
						line-height: 36upx;
					}
					.name-info-vie{
						display: flex;
						.name-info-vie-fl{
							width: 50%;
							font-size: 20upx;
							font-weight: bold;
							color: #333333;
							line-height: 36upx
						}
					}
					.memberTyp{
						line-height: 36upx;
						border: 2upx solid #DBC291;
						border-radius: 18upx;
						font-size: 20upx;
						font-weight: bold;
						color: #DBC291;
						padding: 0 20upx;
						margin-top: 10upx;
						box-sizing: border-box;
						float: left;
					}
					.vipclass{
						width: 250upx;
						height: auto;
					}
				}
			}
		}
		.main-list.type{
			.main-list-for{
				width: 50%;
			}
		}
		.main-list{
			display: flex;
			align-items: center;
			flex-wrap:wrap;
			border-bottom: 1upx solid #ededed;
			width: 100%;
			.main-list-for{
				width: 25%;
				box-sizing: border-box;
				border-left: 1upx solid #ededed;
				border-top: 1upx solid #ededed;
				text-align: center;
				padding: 20upx 0;
				position: relative;
				.num{
					font-size:30upx;
					font-family:'DINCond';
					font-weight:400;
					color:rgba(51,51,51,1);
					line-height:48upx;
				}
				.name{
					font-size:20upx;
					font-weight:500;
					color:rgba(153,153,153,1);
					line-height:30upx;
					height: 60upx;
				}
			}
			.main-list-for:first-child{
				border-left: none;
			}
		}
		.main-list-footre{
			padding: 20upx 30upx;
			box-sizing: border-box;
		}
		.list-but{
			width: 100%;
			height: 70upx;
			line-height: 70upx;
			text-align: center;
			background: #000000;
			border-radius: 35px;
			font-size: 26upx;
			font-weight: bold;
			color: #FFFFFF;
		}
		.list-text{
			text-align: center;
			font-size: 20upx;
			font-weight: 500;
			color: #999996;
			line-height: 29upx;
			margin-top: 20upx;
		}
	}
	.main-list-info{
		margin-top: 20upx;
		background: #FFFFFF;
	}
	.main-top-title{
		padding: 20upx 30upx;
		display: flex;
		justify-content: space-between;
		.main-top-title-fl{
			font-size:30upx;
			font-weight:bold;
			color:rgba(51,51,51,1);
			padding-right: 38upx;
			background: url('https://static.xpandago.net/wechat/images/tc_tipicon%402x.png') no-repeat right center;
			background-size: 26upx;
		}
	}
	.guize-pos{
	  position: fixed;
	  width: 100%;
	  height: 100%;
	  z-index: 10000;
	  left: 0;
	  top: 0;
	  .guize-pos-bj{
	    position: absolute;
	    left: 0;
	    top: 0;
	    z-index: 1001;
	    background: #000000;
	    opacity: 0.3;
	    width: 100%;
	    height:100%;
	  }
	  .guize-pos-centent{
	    width: 540upx;
	    background:rgba(255,255,255,1);
	    border-radius:24upx;
	     position: absolute;
	     z-index: 1002;
	     left: 50%;
	     top: 50%;
			   transform: translate(-50%, -50%);
	     box-sizing: border-box;
	     padding: 30upx;
			   .guize-pos-centent-tltle{
				   text-align: center;
				   font-size: 28upx;
				   font-weight: bold;
				   color: #333333;
				   line-height: 46upx;
			   }
			   .guize-pos-centent-main{
				   .guize-pos-centent-main-list{
					   display: flex;
					   justify-content: space-between;
					   align-items: center;
					   margin-top: 30upx;
					   .guize-pos-centent-main-list-fl{
						   display: flex;
						   align-items: center;
						   .num{
							   font-size: 26upx;
							   font-weight: bold;
							   font-style: italic;
							   color: #333333;
							   line-height: 41upx;
						   }
						   .img{
							   width: 35upx;
							   height: auto;
							   margin-left: 20upx;
						   }
						   .text{
							   margin-left: 20upx;
							   font-size: 24upx;
							   font-weight: 500;
							   color: #333333;
							   line-height: 41upx;
						   }
					   }
					   .guize-pos-centent-main-list-fr{
						   .but{
							   width: 114upx;
							   height: 45upx;
							   line-height: 45upx;
							   background: #070506;
							   border-radius: 23px;
							   text-align: center;
							   font-size: 22upx;
							   font-weight: bold;
							   color: #FFFFFF;
						   }
					   }
					   .fr-img{
						   width: 45upx;
						   height: auto;
						   margin-right: 35upx;
					   }
				   }
			   }
	     .close{
	       position: absolute;
	       width: 60upx;
	       height: auto;
	       bottom: -80upx;
	       left: 50%;
	       margin-left: -30upx;
	       z-index: 1003;
	     }
	  }
	}
</style>
<template>
	<view>
		<view class="top-main">
			<view class="main-top">
				<view class="main-top-top">
					<view class="main-top-top-fl" @tap="tapTishi(0)">用户级别</view>
				</view>
				<view class="main-top-fl">
					<image v-if="dataTop.headIco!='' && dataTop.headIco!=null && dataTop.headIco!=undefined" :src= "'https://static.xpandago.net'+'/'+dataTop.headIco" class="touxiang"></image>
					<image v-else src='https://static.xpandago.net/wechat/images/logo.png' class="touxiang"></image>
					<view class="name-info">
						<view class="name">{{dataTop.username}}</view>
						<view class="name-info-vie">
							<view class="name-info-vie-fl">当前级别：{{dataTop.memberTypeNow}}</view>
							<view class="name-info-vie-fl">上月级别：{{dataTop.memberTypeLast}}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="main-list-info">
				<view class="main-top-title">
					<view class="main-top-title-fl" @tap="tapTishi(1)">团队经营类奖金</view>
				</view>
				<view class="main-list">
					<view class="main-list-for" v-for="(item,i) in dataTop.breedPrices">
						<view class="num">{{item.money}}</view>
						<view class="name">{{item.title}}</view>
					</view>
				</view>
				<view class="main-list-footre">
					<view class="list-but" @tap="apply">可申领  ¥ {{dataTop.breedMoney}}</view>
				</view>
			</view>
			<!-- <view class="main-list-info">
				<view class="main-top-title">
					<view class="main-top-title-fl" @tap="tapTishi(2)">品牌推广津贴</view>
				</view>
				<view class="main-list type">
					<view class="main-list-for" v-for="(item,i) in dataTop.teamPrices">
						<view class="num">{{item.money}}</view>
						<view class="name">{{item.title}}</view>
					</view>
				</view>
				<view class="main-list-footre">
					<view class="list-but" @tap="tapTishi(3)">可提现  ¥ {{dataTop.teamAward}}</view>
					<view class="list-text">提现请前往熊猫出没APP，进行操作</view>
				</view>
			</view> -->
		</view>
		
		
		<view class="guize-pos" v-if="renzenShow==true">
			<view class="guize-pos-bj" @tap.stop="guizeHide"></view>
			<view class="guize-pos-centent">
				<view class="guize-pos-centent-tltle">完成下列任务后，才能申领奖金哦</view>
				<view class="guize-pos-centent-main">
					<view class="guize-pos-centent-main-list" v-for="(item,i) in renwu">
						<view class="guize-pos-centent-main-list-fl">
							<view class="num">{{i+1}}</view>
							<image src="https://static.xpandago.net/wechat/images/wcsm@2x.png" class="img" mode="widthFix"></image>
							<view class="text">{{item.showname}}</view>
						</view>
						<image src="https://static.xpandago.net/wechat/images/qr@2x.png" v-if="item.suctaskvalue>=item.taskvalue" class="fr-img" mode="widthFix"></image>
						<view class="guize-pos-centent-main-list-fr"  v-else>
							<view class="but" v-if="item.mestype==6" @tap="openGoods(item.mestype,i)">去认证</view>
							<view class="but" v-else-if="item.mestype==5" @tap="openGoods(item.mestype,i)">去完善</view>
							<view class="but" v-else-if="item.mestype==12" @tap="openGoods(item.mestype,i)">去完成</view>
						</view>
					</view>
					<!-- <view class="guize-pos-centent-main-list">
						<view class="guize-pos-centent-main-list-fl">
							<view class="num">2</view>
							<image src="https://static.xpandago.net/wechat/images/wsgr@2x.png" class="img" mode="widthFix"></image>
							<view class="text">完善个人信息</view>
						</view>
						<image src="https://static.xpandago.net/wechat/images/qr@2x.png" v-if="renwu[1].suctaskvalue>=renwu[1].taskvalue" class="fr-img" mode="widthFix"></image>
						<view class="guize-pos-centent-main-list-fr" v-else @tap="openGoods(1)">去完善</view>
					</view>
					<view class="guize-pos-centent-main-list">
						<view class="guize-pos-centent-main-list-fl">
							<view class="num">3</view>
							<image src="https://static.xpandago.net/wechat/images/wctx@2x.png" class="img" mode="widthFix"></image>
							<view class="text">完成提现任务</view>
						</view>
						<image src="https://static.xpandago.net/wechat/images/qr@2x.png" v-if="renwu[2].suctaskvalue>=renwu[2].taskvalue" class="fr-img" mode="widthFix"></image>
						<view class="guize-pos-centent-main-list-fr" v-else @tap="openGoods(2)">去完成</view>
					</view> -->
				</view>
				<image src="https://static.xpandago.net/wechat/images/closed_boxs%402x.png" @tap.stop="guizeHide" class="close" mode="widthFix"></image>
			</view>
		</view>
	</view>
</template>

<script>
	import api from '@/common/api';
	import webView from '@/common/webView'
	export default {
		data() {
			return {
				dataTop: {},
				renwu:[],
				token:'',
				renzenShow:false,
			}
		},
		onLoad() {
			this.token=uni.getStorageSync('token')
			// this.token='eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiLllJDkvK_omY7ngrnomorpppnvvIEiLCJhdWRpZW5jZSI6ImUxMGFkYzM5NDliYTU5YWJiZTU2ZTA1N2YyMGY4ODNlIiwidXNlcl9pZCI6NjQzNzIsImNyZWF0ZWQiOjE2MzE2NzUwMTMxNTUsImV4cCI6MTYzNDI2NzAxMywidXNlcl9ncm91cF9pZCI6bnVsbCwicGxhdGZvcm0iOm51bGx9.SGC_TkFRmFpoCHm2FPzdrkznc5GTMIJ4C_MHsBG2eaue_s0Y6orexOoPxc3DqwyGH8Gz-MvN5pJeBKq0R-5GHw'
			this.teambreed()
			// let token=this.getQueryVariable('token');
			// this.token=uni.getStorageSync('token')
			// let code=this.GetQueryString('code');
			// console.log(code)
			// var pages = getCurrentPages(); // 当前页面
			// var beforePage = pages[pages.length - 1]; // 获取当前页面的对象
			// var url = beforePage.route //当前页面url
			// uni.setStorageSync('url', url);
			// console.log(url)
			// if(token!=false){
			// 	uni.setStorageSync('token', token);
			// 	this.token=token
			// 	this.teambreed()
			// }else if(this.token!=null && this.token !='' && this.token != undefined){
			// 	this.teambreed()
			// }else if(code!=null && code !='' && code != undefined){
			// 	this.loginCode(code)
			// }else{
			// 	uni.showToast({
			// 		title: '请先登录！',
			// 		icon: 'none'
			// 	})
			// 	setTimeout(() => {
			// 		uni.reLaunch({
			// 		  url: "/pages/login/loginWechat"
			// 		})
			// 	}, 1000);
			// }
		},
		//下拉刷新
		 onPullDownRefresh() {
			//监听下拉刷新动作的执行方法，每次手动下拉刷新都会执行一次
			this.teambreed()
			setTimeout(function () {
				uni.stopPullDownRefresh();  //停止下拉刷新动画
			}, 1000);
		},
		methods: {
			tapTishi(type){
				let centent=''
				if(type==0){
					centent=this.dataTop.hintList[0]
				}else if(type==1){
					centent=this.dataTop.hintList[1]
					// centent='团队经营类奖金，为1小时更新1次，本月预估奖金与最终实际申领金额可能有一定差别，请以最终申领奖金为准，本月10号显示上月可申领奖金；上月奖金截止更新时间为本月10号，故可能由于退款而导致上月奖金变动；'
				}else if(type==2){
					centent=this.dataTop.hintList[2]
					// centent='品牌推广津贴，为1小时更新1次，本月预估奖金与最终实际发放金额可能有一定差别，请以最终发放奖金为准；上月奖金截止更新时间为本月10号，故可能由于退款而导致上月奖金变动；'
				}else if(type=3){
					centent='提现请前往熊猫出没APP，进行操作'
				}
				uni.showModal({
				  title: '提示',
				  content: centent,
				  showCancel: false, // 是否显示取消按钮
				  success: function(res) {
				    if (res.confirm) {
				        // 确定按钮
				        // console.log(id)
				    } else if (res.cancel) {
				    }
				  }
				})
			},
			//认证完成信息
			// tapRenz(type){
			// 	this.openGoods(type)
			// },
			//返回app
			openGoods(type,index){
				let userStr = navigator.userAgent
				let that=this
				if (userStr.indexOf('Android') !== -1) {
					if(type==6){
						let params={type:'Ard_RealName'}
						window.Android.showInfoFromJs(JSON.stringify(params))
					}else if(type==5){
						let params={type:'Ard_Account'}
						window.Android.showInfoFromJs(JSON.stringify(params))
					}else if(type==12){
						let params={type:'VC_ClientList',url:that.renwu[index].urlJson.android.url}
						window.Android.showInfoFromJs(JSON.stringify(params))
						// if(that.renwu[index].urlJson.android.url!='' && that.renwu[index].urlJson.android.url!=null){
						// 	window.location.href=that.renwu[index].urlJson.android.url
						// }else{
						// 	let params={type:'VC_ClientList',url:that.renwu[index].urlJson.android.url}
						// 	window.Android.showInfoFromJs(JSON.stringify(params))
						// }
					}
					// let params={orderType:'GJorder',OrderNo:orderNo}
					// window.Android.Ard_RealName(JSON.stringify(params))
				} else {
					if(type==6){
						webView.callhandler(
						  "JumpNativePage",
						  {
							Module: that.renwu[index].urlJson.ios.Module,
							params: JSON.stringify(that.renwu[index].urlJson.ios.params),
						  },
						  (data) => {}
						)
					}else if(type==5){
						webView.callhandler(
						  "JumpNativePage",
						  {
							Module: that.renwu[index].urlJson.ios.Module,
							params: JSON.stringify(that.renwu[index].urlJson.ios.params),
						  },
						  (data) => {}
						)
					}else if(type==12){
						if(that.renwu[index].urlJson.ios.url!='' && that.renwu[index].urlJson.ios.url!=null){
							window.location.href=that.renwu[index].urlJson.ios.url
						}else{
							webView.callhandler(
							  "JumpNativePage",
							  {
								Module: that.renwu[index].urlJson.ios.Module,
								params: JSON.stringify(that.renwu[index].urlJson.ios.params),
							  },
							  (data) => {}
							);
						}
					}
					
				  // webView.callhandler(
				  //   "JumpNativePage",
				  //   {
				  // 	Module: "VC_PayChoice",
				  // 	params: JSON.stringify({
				  // 	  orderType: 'GJorder',
				  // 	  OrderNo: orderNo,
					 //  ShouldPresent: 1
				  // 	}),
				  //   },
				  //   (data) => {}
				  // );
				}
			},
			
			//任务完成情况
			async getTasksWithdrawal(){
				// let sss='eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiLmtYvor5XpnLgiLCJhdWRpZW5jZSI6ImUxMGFkYzM5NDliYTU5YWJiZTU2ZTA1N2YyMGY4ODNlIiwidXNlcl9pZCI6NzA0NjQsImNyZWF0ZWQiOjE2MzA1NjgxMjk5NzAsImV4cCI6MTYzMzE2MDEyOSwidXNlcl9ncm91cF9pZCI6bnVsbH0.hUBIpaSZvalmue7XZeu4YX8Zx13xWTWv9DIrYrpRDAZhkYWPiybW6dX75BMVXwneloO7SAjPMK-0TNmDDRV68A'
				const [err, res] = await api.getTasksWithdrawal({
					 header:{
						'Content-Type': 'application/json',
						// 'token': sss
						'token': this.token
					 }
				 });
				 if(res.data.code == 0){
					 let rwList=res.data.data
					 let centent="确定申领¥"+ this.dataTop.breedMoney +"奖金吗? 点击确认，完成申领，申领后可在熊猫出没APP，进行提现"
					 let that=this
					 let litsType=[]
					 for(let i=0; i<rwList.length; i++){
						 if(rwList[i].mestype==12 && rwList[i].publishtype==2){
							 litsType.push(rwList[i])
						 }
					 }
					 let index=0
					 for(let i=0; i<litsType.length; i++){
						 if(litsType[i].suctaskvalue<litsType[i].taskvalue && litsType[i].publishtype==2){
							 index=i
							 break 
						 }
					 }
					 this.renwu=rwList.splice(0,3)
					 for(let i=0; i<this.renwu.length; i++){
						 if(this.renwu[i].mestype==12){
							 this.renwu.splice(i,1)
							 this.renwu.push(litsType[index])
						 }
					 }
					 if(this.renwu!='' && this.renwu!=null){
						 for(let i=0; i<this.renwu.length; i++){
							 if(this.renwu[i].suctaskvalue<this.renwu[i].taskvalue){
								 this.renzenShow=true
								 return false
							 }
						 }
						 if(this.renzenShow==false){
							 uni.showModal({
							   title: '提醒',
							   content: centent,
							   // showCancel: false, // 是否显示取消按钮
							   success: function(res) {
							     if (res.confirm) {
							         // 确定按钮
									 that.apply()
							         // console.log(id)
							     } else if (res.cancel) {
							     }
							   }
							 })
						 }
					 }else{
						uni.showModal({
						  title: '提醒',
						  content: centent,
						  // showCancel: false, // 是否显示取消按钮
						  success: function(res) {
						    if (res.confirm) {
						        // 确定按钮
								 that.apply()
						        // console.log(id)
						    } else if (res.cancel) {
						    }
						  }
						}) 
					 }
				 }else{
					 uni.showToast({
					 	title: res.data.msg,
					 	icon: 'none'
					 })
				 }
			},
			//申领团队经营奖
			async apply(){
				const [err, res] = await api.apply({
					 header:{
					 'Content-Type': 'application/x-www-form-urlencoded',
					 'token':this.token
					 },
					 method:'POST'
				 });
				 if(res.data.code == 0){
					 let dataInfo=res.data.data
					 uni.showModal({
					   title: '提醒',
					   content: dataInfo,
					   // showCancel: false, // 是否显示取消按钮
					   success: function(res) {
					     if (res.confirm) {
					         // 确定按钮
					         // console.log(id)
					     } else if (res.cancel) {
					     }
					   }
					 })
					 // this.dataTop=res.data.data
				 }else{
					 uni.showToast({
					 	title: res.data.msg,
					 	icon: 'none'
					 })
				 }
			},
			//XPG团队奖管理
			async teambreed(){
				const [err, res] = await api.teambreed({
					 header:{
						'Content-Type': 'application/json',
						'token': this.token
					 }
				 });
				 console.log(res)
				 if(res.data.code == 0){
					 this.dataTop=res.data.data
				 }else{
					 uni.showToast({
					 	title: res.data.msg,
					 	icon: 'none'
					 })
				 }
			},
			guizeHide(){
				this.renzenShow=false
			}
		}
	}
</script>
